<template>
    <div>
        <table>
            <tbody>
                <tr>
                    <td>会员名称</td>
                    <td>
                        <input type="text" v-model="data.Hname" >
                    </td>
                </tr>
                <tr>
                    <td>会员时间</td>
                    <td>
                        <input type="date" v-model="data.Htime">
                    </td>
                </tr>
                <tr>
                    <td>会员性别</td>
                    <td>
                        <input type="radio" name="Xingbie" value="1" v-model="data.Xingbie">男
                        <input type="radio" name="Xingbie" value="2" v-model="data.Xingbie">女
                    </td>
                </tr>
                <tr>
                    <td>会员手机号</td>
                    <td>
                        <input type="text" v-model="data.Phone">
                    </td>
                </tr>
                <tr>
                    <td>会员地址</td>
                    <td>
                        <input type="text" v-model="data.Adds">
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <input type="button" value="添加" @click="add" >
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">

import { ref } from 'vue';
import axios from 'axios';
import { useRoute } from 'vue-router';








const rounter=useRoute();

const data=ref({
  "Hid": 0,
  "Hname": "",
  "Htime": "",
  "Xingbie": 0,
  "Phone": "",
  "Adds": ""
});
const add=()=>{
    if(data.value.Hname=="")
    {
        alert("会员名称不能为空");
        return;
    }
    if(data.value.Htime=="")
    {
        alert("会员时间不能为空");
        return;
    }
    if(data.value.Phone=="")
    {
        alert("手机号不能为空");
        return;
    }
    if(data.value.Adds=="")
    {
        alert("会员地址不能为空");
        return;
    }
    console.log(data.value);
    axios.post("https://localhost:7016/api/hui/AddHui",data.value).then(res=>{
        if(res.data>0)
    {
        alert("添加成功");
        //rounter.push({path:"/"});
    }
    else
    {
        alert("添加失败");
    }
})}





</script>

<style scoped>

</style>